<div class="row">
    <p id="list-title">{{.PageName}}</p>
</div>

<form id="productUomForm" action="{{.URL}}{{.RecordID}}?action={{.Action}}" method="post" class="post-form form-horizontal {{if .Readonly}}form-disabled{{else}}form-edit{{end}}" role="form">
    <div class="row title-action">
        {{if .RecordID}} {{if .Readonly}}
        <a href="{{.URL}}{{.RecordID}}?action=edit" class="btn btn-success fa fa-pencil pull-left form-edit-btn">&nbsp编辑</a>
        <a href="{{.URL}}?action=create" type="buttom" class="btn btn-success fa fa-plus pull-left form-create-btn">&nbsp新建</a>{{end}}{{end}}
        <button type="submit" form="productUomForm" class="btn btn-primary fa fa-save pull-left form-save-btn">&nbsp保存</button> {{if .Readonly}}
        <button type="button" class="btn btn-danger fa fa-remove  pull-left form-cancel-btn">&nbsp取消</button> {{else}}
        <a href="{{.URL}}" class="btn btn-danger fa fa-remove  pull-left">&nbsp取消</a> {{end}}
        <a href="{{.URL}}" class="btn btn-info fa fa-list pull-left">&nbsp列表</a>
    </div>
    {{ .xsrf }} {{if .RecordID}}
    <input type="hidden" data-type="int" class="{{.FormField}}" name="recordID" id="record-id" value="{{.RecordID}}"> {{end}}
    <fieldset>
        <legend>基本信息</legend>
        <div class="row">
            <div class="col-md-3">
                <div class="form-group">
                    <label for="category" class="col-md-4 control-label label-start">计量单位类别<span class="required-input">&nbsp*</span></label>
                    <div class="col-md-8">
                        <p class="p-form-control">{{if .Uom}} {{.Uom.Category.Name}} {{end}}</p>
                        <select data-type="int" name="Category" id="category" autofocus class="{{.FormField}} form-control select-product-uom-category">
                            {{if .Uom}} {{if .Uom.Category}} 
                            <option value="{{.Uom.Category.ID}}}" selected="selected">{{.Uom.Category.Name}}</option> 
                             {{end}} {{end}}
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-md-3">
                <div class="form-group">
                    <label for="name" class="col-md-4 control-label label-start">计量单位名称<span class="required-input">&nbsp*</span></label>
                    <div class="col-md-8">
                        <p class="p-form-control">{{if .Uom}} {{.Uom.Name}} {{end}}</p>
                        <input data-type="string" class="{{.FormField}} form-control" name="Name" type="text" {{if .Uom}} value="{{.Uom.Name}}" {{end}} />
                    </div>
                </div>
            </div>
            <div class="col-md-3">
                <div class="form-group">
                    <label for="active" class="col-md-4 control-label ">有效</label>
                    <div class="col-md-8 ">
                        <input name="Active" id="active" class="{{.FormField}} form-control form-checkbox" checked="checked" type="checkbox">
                    </div>
                </div>
            </div>
            <div class="col-md-3">
                <div class="form-group">
                    <label for="rounding" class="col-md-4 control-label label-start">舍入精度<span class="required-input">&nbsp*</span></label>
                    <div class="col-md-8">
                        <p class="p-form-control">{{if .Uom}} {{.Uom.Rounding}} {{end}}</p>
                        <input data-type="float" class="{{.FormField}} form-control" name="Rounding" type="text" {{if .Uom}} value="{{.Uom.Rounding}}" {{else}}value="0.01" {{end}} />
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-md-3">
                <div class="form-group">
                    <label for="type" class="col-md-4 control-label label-start">类型<span class="required-input">&nbsp*</span></label>
                    <div class="col-md-8">
                        <p class="p-form-control"> {{if .Uom}} {{.Uom.TypeName}}{{end}}</p>
                        <select data-type="int" name="Type" id="type" class="{{.FormField}} form-control select-product-uom-category-type">
                             {{if .Uom}} 
                            <option value="{{.Uom.Type}}" selected="selected">{{.Uom.TypeName}}</option>
                            {{else}}<option value="2" selected="selected">参考计量单位</option>{{end}} 
                        </select>
                    </div>
                </div>
            </div>
            <div id="factorDisplay" class="col-md-3 hidden">
                <div class="form-group">
                    <label for="factor" class="col-md-4 control-label ">比率</label>
                    <div class="col-md-8 ">
                        <input data-type="float" name="Factor" id="factor" type="text" step="0.01" {{if .Uom}}value="{{.Uom.Factor}}" {{else}} value="10" {{end}} class="{{.FormField}} form-control" />
                    </div>
                </div>
            </div>
            <div id="factorInvDisplay" class="col-md-3 hidden">
                <div class="form-group">
                    <label for="factorInv" class="col-md-4 control-label ">更大比率</label>
                    <div class="col-md-8 ">
                        <input data-type="float" name="FactorInv" id="factorInv" type="text" step="0.01" {{if .Uom}}value="{{.Uom.FactorInv}}" {{else}} value="10" {{end}} class="{{.FormField}} form-control" />
                    </div>
                </div>
            </div>
            <div id="symbol" class="col-md-3">
                <div class="form-group">
                    <label for="symbol" class="col-md-4 control-label ">符号</label>
                    <div class="col-md-8 ">
                        <p class="p-form-control">{{if .Uom}} {{.Uom.Symbol}} {{end}}</p>
                        <input data-type="string" name="Symbol" id="symbol" type="text" {{if .Uom}}value="{{.Uom.Symbol}}" {{end}} class="{{.FormField}} form-control" />
                    </div>
                </div>
            </div>
        </div>
    </fieldset>
</form>